clear all;
clc;

load mnist_all

c = 3;
n = zeros(10,1);
for i = 1:10
    n(i) = size(eval(strcat('train',int2str(i-1))),1);
end

label = [ones(n(1),1);2*ones(n(2),1);3*ones(n(3),1);4*ones(n(4),1);5*ones(n(5),1);6*ones(n(6),1);7*ones(n(7),1);8*ones(n(8),1);9*ones(n(9),1);10*ones(n(10),1)];
label = uint8(label);
idx = randperm(size(label,1));
label = int8(label(idx,:));
data = [train0;train1;train2;train3;train4;train5;train6;train7;train8;train9];
data = data(idx,:);

save('mnist_train_all','data','label');